﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using lauimini_webform.BLL;

namespace courseWork
{
    public partial class Register : System.Web.UI.Page
    {
        UserService userService;
        public Register()
        {
             userService = new UserService();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            new InitMenu().initData();
        }

        protected void Register_Click(object sender, EventArgs e)
        {
            string userName = Request.Form["userName"];
            string userAccount = Request.Form["userAccount"];
            string password = Request.Form["password"];

            bool situation = userService.checkRepateUser(userAccount, password);
            if (situation)
            {
                Response.Write("<script>alert('该用户已经注册')</script>");
             
                return;
            }

            bool isSuccess = userService.addUser(userName, userAccount, password);
            if (isSuccess)
            {       
                Response.Write("<script>alert('注册成功');location.href='Login.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('账号已注册');</script>");
            }

            
        }
    }
}